package com.weishi.project.training.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.weishi.framework.aspectj.lang.annotation.Log;
import com.weishi.framework.aspectj.lang.enums.BusinessType;
import java.util.Arrays;
import com.weishi.project.training.domain.HeartRateCount;
import com.weishi.project.training.service.IHeartRateCountService;
import com.weishi.framework.web.controller.BaseController;
import com.weishi.framework.web.domain.AjaxResult;
import com.weishi.common.utils.poi.ExcelUtil;
import com.weishi.framework.web.page.TableDataInfo;

/**
 * 心率计次数据Controller
 */
@RestController
@RequestMapping("/training/heartRateCount")
public class HeartRateCountController extends BaseController {

    @Autowired
    private IHeartRateCountService heartRateCountService;

    /**
     * 查询心率计次数据列表
     */
    @PreAuthorize("@ss.hasPermi('training:count:list')")
    @GetMapping("/list")
    public TableDataInfo list(HeartRateCount heartRateCount) {
        startPage();
        List<HeartRateCount> list = heartRateCountService.selectHeartRateCountList(heartRateCount);
        return getDataTable(list);
    }

    /**
     * 导出心率计次数据列表
     */
    @PreAuthorize("@ss.hasPermi('training:count:export')")
    @Log(title = "心率计次数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HeartRateCount heartRateCount) {
        List<HeartRateCount> list = heartRateCountService.selectHeartRateCountList(heartRateCount);
        ExcelUtil<HeartRateCount> util = new ExcelUtil<HeartRateCount>(HeartRateCount.class);
        return util.exportExcel(list, "count");
    }

    /**
     * 获取心率计次数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('training:count:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(heartRateCountService.getById(id));
    }

    /**
     * 新增心率计次数据
     */
    @PreAuthorize("@ss.hasPermi('training:count:add')")
    @Log(title = "心率计次数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HeartRateCount heartRateCount) {
        heartRateCountService.save(heartRateCount);
        return AjaxResult.success();
    }

    /**
     * 修改心率计次数据
     */
    @PreAuthorize("@ss.hasPermi('training:count:edit')")
    @Log(title = "心率计次数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HeartRateCount heartRateCount) {
        heartRateCountService.updateById(heartRateCount);
        return AjaxResult.success();
    }

    /**
     * 删除心率计次数据
     */
    @PreAuthorize("@ss.hasPermi('training:count:remove')")
    @Log(title = "心率计次数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        heartRateCountService.removeByIds(Arrays.asList(ids));
        return AjaxResult.success();
    }
    
}